<template>
	<view class="content">
		<u-sticky bgColor="#fff">
			<u-tabs :list="list" :is-scroll="false" style="" :current="current" @change="change"></u-tabs>
		</u-sticky>
		<view v-for="(item,index) in applyList" :key="index">
			<u-card :title="item.name+'('+item.phone+')'" padding="30" margin="26rpx" :sub-title="item.className">
				<view class="" slot="body">
					<view class="u-body-item-title u-line-2">审核状态：{{ applyStatus(item.status) }}</view>
					<view v-if="item.status===1 && item.userId">
						<view class="u-body-item-title u-line-2">账号：{{ item.account }}</view>
						<view class="u-body-item-title u-line-2">密码:使用默认密码</view>
					</view>
				</view>
				<view slot="foot">
					<uni-collapse>
						<uni-collapse-item title="审核备注">
							<view class="content">
								<text class="text">{{ item.remark ? item.remark : "" }}</text>
							</view>
						</uni-collapse-item>
					</uni-collapse>
				</view>
			</u-card>
		</view>
	</view>
</template>

<script>
	import {
		getApplyListBySchoolId
	} from '@/api/jz/apply/info'
	import {
		getInfoId
	} from '@/utils/auth';

	export default {
		data() {
			return {
				applyList: [],
				list: [{
					name: '审核通过'
				}, {
					name: '全部'
				}, {
					name: '审核未通过'
				}],
				current: 1,
				value: 0,
			}
		},
		methods: {
			change(value) {
				// case 0 1 2代表上面三个  [{name: '审核通过'}, {name: '全部'}, {name: '审核未通过'}],
				// value 代表审核状态 1审核通过 0全部数据  2审核未通过
				switch (value) {
					case 0:
						this.value = 1
						break;
					case 1:
						this.value = 0
						break;
					case 2:
						this.value = 2
						break;
				}
				this.current = value;
				this.getApplyListBySchoolIdFun(this.value)
			},
			applyStatus(value) {
				let str = '';
				switch (value) {
					case -1:
						str = "待审核"
						break;
					case 1:
						str = "审核通过"
						break;
					case 2:
						str = "审核未通过"
						break;
				}
				return str;
			},
			getApplyListBySchoolIdFun(status) {
				getApplyListBySchoolId(getInfoId(), status).then(response => {
					if (response.code === 200) {
						this.applyList = response.rows
					}
				})
			}

		},
		onLoad: function() {
			this.getApplyListBySchoolIdFun(this.value)
		}
	}
</script>

<style scoped>
	page {
		height: 100%;
		background-color: #f2f2f2;
	}
</style>
<style scoped lang="scss">
	.mini-btn {
		margin-left: 5px;
	}

	.u-card-wrap {
		background-color: $u-bg-color;
		padding: 1px;
	}

	.u-body-item {
		font-size: 32 rpx;
		color: #333;
		padding: 20 rpx 10 rpx;
	}

	.u-body-item image {
		width: 120 rpx;
		flex: 0 0 120 rpx;
		height: 120 rpx;
		border-radius: 8 rpx;
		margin-left: 12 rpx;
	}
</style>